/**
 * Created by Administrator on 2016/6/29.
 */

module.exports.resize = function () {
  var ww = $(window).width();
  var wh = $(window).height();
  calcChatSize(ww, wh);
};

//初始化窗口大小
var win_w = $(window).width();
var win_h = $(window).height();
var ratio_w = 0.68;
var ratio_h = 0.88;
calcChatSize(win_w, win_h);

//窗口大小自适应
$(window).resize(function () {
  var ww = $(window).width();
  var wh = $(window).height();
  calcChatSize(ww, wh);
});

//窗口大小动态设置
function calcChatSize(width, height) {
  $('.im-wrap').css({
    'width': width * ratio_w + 'px',
    'margin-left': width * (1 - ratio_w) / 2 + 'px',
    'margin-top': height * (1 - ratio_h) / 2 + 'px'
  });
  $('.im-chat-list').css({'height': (height * ratio_h - 275) + 'px'});
  $('.im-clue-info').css({'height': (height * ratio_h - 78) + 'px'});
  $('.im-right-sidebar').css({'height': ($('.im-chat-window').height() + 2) + 'px'});
  $('.im-view-pic').css({'width': width, 'height': height});
  var imgs = $('.im-view-pic img');
  $.each(imgs, function (index, img) {
    var $img = $(img);
    var img_w = $img.width();
    var img_h = $img.height();
    $img.css({'margin-left': (width - img_w) / 2 + 'px', 'margin-top': (height - img_h) / 2 + 'px'});
  });
}
